package com.zsrt.java.day20161226.wrl.day161226.demo05;

public class TriDemo {
	
	public static void main(String[] args) {
		/*for (int outer = 1; outer <= 5; outer++) {
			//1.先打星型
			for (int inner = 1; inner <= outer; inner++) {
				System.out.print("*");
			}
			//2.打回车
			System.out.println();
		}*/
		
		printStar01();
		System.out.println("-----------------------");
		printStar02(10);
		System.out.println("-----------------------");
		printStar03(5,10);
	}
	
	public static void printStar01(){
		for (int outer = 1; outer <= 5; outer++) {
			//1.先打星型
			for (int inner = 1; inner <= outer; inner++) {
				System.out.print("*");
			}
			//2.打回车
			System.out.println();
		}
	}

	/**
	 * 优化 1
	 * @param count
	 */
	public static void printStar02(int count){
		for (int outer = 1; outer <= count; outer++) {
			//1.先打星型
			for (int inner = 1; inner <= outer; inner++) {
				System.out.print("*");
			}
			//2.打回车
			System.out.println();
		}
	}
	
	/**
	 * 优化 2
	 * @param begin
	 * @param count
	 */
	public static void printStar03(int begin,int count){
		for (int outer = begin; outer <= count; outer++) {
			//1.先打星型
			for (int inner = 1; inner <= outer; inner++) {
				System.out.print("*");
			}
			//2.打回车
			System.out.println();
		}
	}
}
